(function($) {
	var arkflow = $.arkflow;

	//显示属性编辑框
	arkflow.PropertyEditor = Base.extend({
        currNode: null,
        constructor: function(event, workflow) {
            this.paper = workflow.paper;
            this.init();
        },
        init: function() {
            this.div = $("#arkflow_props").hide().draggable({
                handle : "#arkflow_props_handle"
            }).resizable().css(arkflow.config.props.attr).bind("click", function() {
                    return false;
                });
            this.table = this.div.find("table");

            $(this.paper).bind("showprops", this.showprops.bind(this));
        },
        destoryEditors: function() {
            $(this.table).find(".editor").each(function() {
                var editor = $(this).data("editor");
                if (editor) {
                    editor.destroy();
                }
            });
            this.table.empty();
        },
        showprops: function(event, states, node) {
            if (this.currNode && this.currNode.getId() == node.getId()) {
                return;
            }

            this.currNode = node;

            this.destoryEditors();

            this.div.show();
            for (var state in states) {
                this.table.append("<tr><th>" + states[state].label + '</th><td><div id="p' + state + '" class="editor"></div></td></tr>');
                if (states[state].editor) {
                    states[state].editor().init(states, state, "p" + state, node, this.paper);
                }
            }
        }
    });

    arkflow.editors = {
    };

})(jQuery); 